package com.zixuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zixuan.common.Result;
import com.zixuan.dao.EmployeeDao;
import com.zixuan.entity.EmployeeEntity;
import com.zixuan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private EmployeeDao employeeDao;
    @Override
    public Result login(EmployeeEntity employeeEntity) {
        EmployeeEntity user = employeeDao.selectOne(new QueryWrapper<EmployeeEntity>().eq("username", employeeEntity.getUsername()).eq("password", employeeEntity.getPassword()));
        if(user==null){
            throw new RuntimeException("用户名或密码错误");
        }
        Map<String, Object> map = new HashMap<>();
        map.put("user",user);
        return new Result(200,true,"SUCCESS",map) ;
    }
}
